/*
 * @Author: szx
 * @Date: 2021-11-06 13:02:49
 * @LastEditTime: 2021-11-06 13:15:59
 * @Description:
 * @FilePath: \leetcode\100-199\102\102.cpp
 */
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right)
        : val(x), left(left), right(right) {}
};

class Solution {
   public:
    vector<vector<int>> levelOrder(TreeNode *root) {
        vector<vector<int>> res;
        if (!root) return res;
        queue<TreeNode *> que;
        que.emplace(root);
        while (!que.empty()) {
            int size = que.size();
            vector<int> tmp;
            for (int i = 0; i < size; i++) {
                TreeNode * node = que.front();
                tmp.emplace_back(node->val);
                que.pop();
                if (node->left) que.emplace(node->left);
                if (node->right) que.emplace(node->right);
            }
            res.push_back(tmp);
        }
        return res;
    }
};

int main() { return 0; }